package com.logica.mdm.webfrontend.embedding.adapter;

import org.apache.commons.lang.StringUtils;

import com.logica.mdm.webfrontend.embedding.EmbeddingAdapter;

/**
 * Abstract implementation of an Embedding Adapter, that can be
 * used as a base for concrete implementation.
 * @author Fabien Crespel <fabien.crespel@logica.com>
 */
public abstract class AbstractEmbeddingAdapter implements EmbeddingAdapter {

	public static final String EMBEDDING_ADAPTER_SUFFIX = "EmbeddingAdapter";
	public static final String DEFAULT_THEME_NAME = "default";
	public static final String DEFAULT_SYSTEM_NAME = "Admin";
	
	protected String name;
	protected String themeName = DEFAULT_THEME_NAME;
	protected String systemName = DEFAULT_SYSTEM_NAME;
	
	/**
	 * Get the name of this embedding adapter.
	 * If undefined, the default is the class name minus the 'EmbeddingAdapter'
	 * suffix, and converted to lowercase.
	 * @return adapter name
	 */
	@Override
	public String getName() {
		if (this.name == null)
			this.name = StringUtils.chomp(getClass().getSimpleName(), EMBEDDING_ADAPTER_SUFFIX).toLowerCase();
		return this.name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * Get the theme name to use when using this embedding adapter.
	 * @return theme name
	 */
	@Override
	public String getThemeName() {
		return this.themeName;
	}
	
	/**
	 * Set the theme name to use when using this embedding adapter.
	 * @param themeName theme name
	 * @return theme name
	 */
	public void setThemeName(String themeName) {
		this.themeName = themeName;
	}
	
	/**
	 * Get the system name (defined in MDM Hub) associated with the embedding application.
	 * @return system name
	 */
	@Override
	public String getSystemName() {
		return this.systemName;
	}
	
	/**
	 * Set the system name (defined in MDM Hub) associated with the embedding application.
	 * @param systemName system name
	 * @return system name
	 */
	public void setSystemName(String systemName) {
		this.systemName = systemName;
	}
}
